<template>
    <div class="count">
        <h2>当前求和为: {{ countStore.sum }} </h2>
        <select v-model.number="n">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
        </select>
        <button @click="add">加</button>
        <button @click="minus">减</button>
    </div>
</template>
<script lang="ts" setup name="Count">
import { ref } from 'vue';
import { useCountStore } from '@/store/count';

const n = ref(1)

const countStore = useCountStore();
// 在reactive中的ref,会自动拆包,不需要.value
// 一个reactive对象(Proxy),包含一个sum的ObjectRefImpl响应式对象和一个state对象
console.log("countStore:", countStore.sum, countStore.$state.sum)
function add() {
}
function minus() {
}
</script>
<style scoped>
.count {
    background-color: skyblue;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 0 10px;
}

select,
button {
    margin: 0 5px;
    height: 25px;
}
</style>